package com.ph.website.home.web;

import com.ph.website.home.base.common.CommonResult;
import com.ph.website.home.param.HelpSupportParam;
import com.ph.website.home.param.NewsParam;
import com.ph.website.home.service.IWebService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

//@Controller
public class WebController {

    @Resource
    private IWebService webService;

    @RequestMapping({"/", "/index.html"})
    public String index(){
        webService.index();
        return "index";
    }

    @RequestMapping("/about.html")
    public String about(){

        webService.about();
        return "about";
    }

    @RequestMapping("/detail.html/{newsId}")
    public String detail(@PathVariable("newsId")Integer newsId){
        webService.detail(newsId);
        return "detail";
    }

    @RequestMapping("/help.html")
    public String help(){
        return "help";
    }

    @RequestMapping("/news.html")
    public String news(){
        return "news";
    }

    @RequestMapping("/pro.html")
    public String pro(){
        return "pro";
    }

    @RequestMapping("/pro-0sb.html")
    public String pro0sb(){
        return "pro-0sb";
    }

    @RequestMapping("/pro-edai.html")
    public String proEdai(){
        return "pro-edai";
    }

    @RequestMapping("/pro-myc.html")
    public String proMyc(){
        return "pro-myc";
    }

    @RequestMapping("/pro-wmfw.html")
    public String proWmfw(){
        return "pro-wmfw";
    }

    @RequestMapping("/science.html")
    public String science(){
        return "science";
    }

    @RequestMapping("/science-pra.html")
    public String sciencePra(){
        return "science-pra";
    }

    @RequestMapping("/science-qkl.html")
    public String scienceQkl(){
        return "science-qkl";
    }

    @RequestMapping("/science-xbrl.html")
    public String scienceXbrl(){
        return "science-xbrl";
    }

    /**前端获取帮助支持列表*/
    @RequestMapping("/webApi/helpList")
    @ResponseBody
    public CommonResult helpList(HelpSupportParam.ListParam param){
        return webService.helpList(param);
    }


    /**前端获取新闻列表*/
    @RequestMapping("/webApi/newsList")
    @ResponseBody
    public CommonResult newsList(NewsParam.ListParam param){

        return webService.newsList(param);
    }

    /**打包后的后台页面*/
    @RequestMapping("/houtai")
    public String houtai(){
        return "redirect:/dist/index.html";
    }
}
